#pragma once
#include "common.h"
#include "CenterCache.h"
#include "PageCache.h"


class CenterCache
{
private:
	CenterCache() {}
	CenterCache(const CenterCache&) = delete;
	CenterCache& operator=(CenterCache&) = delete;

public:
	static CenterCache* GetInstance()
	{
		return &_sInst;
	}

	//获取一个span
	Span* BatchOneSpan(SpanList& freeList ,size_t size);

	//从中心缓存获取一定数量的freelist给threadCache
	size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);

	//回收环节回收到中心存储
	void RecycleToCenterStorage(void* start, size_t size);

	// size_t recycleTimes = 0; 测试回收次数
private:
	// std::mutex _recycle_lock; 测试回收次数
	SpanList _spanList[MAX_LIST];
	static CenterCache _sInst;
};